//type define
typedef unsigned char			UINT8;
typedef signed char				INT8;
#if defined(MAC_OS) || defined(ANDROID_OS)
	typedef unsigned char		BYTE;
#endif
typedef unsigned short			UINT16;
typedef signed short			INT16;
typedef unsigned int			UINT32;
typedef signed int				INT32;
typedef unsigned short			UNICHAR;
typedef unsigned long long 		UINT64;

#ifdef MAC_OS
	#define NULL				0
#endif

#define SAFE_DEL(a)					{if(a){delete (a);(a) = NULL;}}
#define SAFE_DEL_ARRAY(a)			{if(a){delete[] (a);(a) = NULL;}}
#define SAFE_DEL_ARRAY_TYPE(a, t)	{if((t)a){delete[] ((t)(a));(a) = NULL;}}
#define SAFE_DEL_ARRAY_OBJ(p, n)	{if (p) {for (int __i = 0; __i < (n); __i++) SAFE_DEL((p)[__i]); SAFE_DEL_ARRAY(p);}}
#define SAFE_DEL_ARRAY_ARRAY(p, n)	{if (p) {for (int __i = 0; __i < (n); __i++) SAFE_DEL_ARRAY((p)[__i]); SAFE_DEL_ARRAY(p);}}
#define CHECK_POINT_IN_RECT(X1,Y1,X,Y,W,H) ((X1)>= (X) && (X1) <= (X)+(W) && (Y1)>=(Y) && (Y1) <= (Y)+(H))
#define CHECK_POINT_IN_CIRCLE(X, Y, CX, CY, RAD) ((X-CX)*(X-CX) + (Y-CY)*(Y-CY) <RAD*RAD)
#define CHECK_TWO_RECT(XA1, YA1, XA2, YA2, XB1, YB1, XB2, YB2) (((XA1 >= XB1 && XA1 <= XB2)||(XB1 >= XA1 && XB1 <= XA2)) && ((YA1 >= YB1 && YA1 <= YB2)||(YB1 >= YA1 && YB1 <= YA2)))
#define CHECK_CIRCLE_AND_RECT(Cx, Cy, Cr, Rx, Ry, Rw, Rh)		(CGame::_this->CheckCircleAndRect(Cx, Cy, Cr, Rx, Ry, Rw, Rh))

#define GET_SPRITE()	(CGame::_this->_sprite)
#define D_TIME()		(CGame::_this->_frame_dt)
#define GL()			(CGame::_this->_g)
#define MSIN(a)	(CGame::_this->Math_Sin(a))
#define MCOS(a)	(CGame::_this->Math_Cos(a))
#define ANGLE_ABS(a) (CGame::_this->Math_AngleAbs(a))

#define ANIMAL_CURRENT_OBJECT()		(GET_CONFIG()._current_total_animal_spawn)
#define GET_GAME()						CGame::_this
#define GET_ITEM(id)				(CGame::_this->_items[id])
#define GET_TOUCH(id)				(CGame::_this->_touches[id])
#define GET_ANIMAL(id)				(CGame::_this->_animal[id])
#define GET_CONFIG()				(CGame::_this->_game_config)
#define GET_PATH(id)				(CGame::_this->_path[id])
#define GET_BALL(id)				(CGame::_this->_balls[id])
#define GET_CRASH(id)				(CGame::_this->_crash[id])
#define GET_TEMP_NUMBER()			(CGame::_this->_temp_number)
#define GET_CURRENT_NUMBER()		(CGame::_this->_current_number)
#define GET_READ_WRITE()			(CGame::_this->r_w)
#define GET_PLATFORM()				(CGame::_this->_platform)
#define GET_ANIMAL_NUMBER(id)			(CGame::_this->_animal_number[id])
#define GET_ANIMAL_BULLET(id)		(CGame::_this->_animal_bullet[id])
#define GET_DEGIGNER(id)			(CGame::_this->_designs[id])
#define GET_WOWTEXT()				(CGame::_this->_wowtexr)
#define GET_W_H_SCREEN				(CGame::_this->_d)
#define GET_OBJECT_PLATFORM()		(CGame::_this->_object_platform)
#define GET_CGAMEVER2()				(CGame::_this->c_gamever2)
#define GET_SCORE()					(CGame::_this->_score)
#define GET_EFFECT()				(CGame::_this->_effect)
#define GET_SHOPMENUITEM(id)		(CGame::_this->_shop_menu_items[id])
#define GET_LBMENUITEM(id)			(CGame::_this->_LB_menu_items[id])

#define SHOP_OBJ(obj_id,field_id) Game_design::SHOP_DESIGN_TABLE[obj_id*SHOP_OBJ_FIELD_NUM + field_id]
#define SHOP_OBJ_LEVEL(obj_id,attribute,level,field_id,data) \
	data[(SHOP_OBJ(obj_id,SHOP_OBJ_FIELD_OFFSET)+(attribute*SHOP_OBJ(obj_id,SHOP_OBJ_FIELD_LEVEL_NUM)+ (level - 1)))*OBJDT_FIELD_NUM + field_id] 